﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SegGen
{
  public  class Segment : IComparable<Segment>
    {

        private int m_segmentSize;
        private int m_minSegmentSize;

        public int MinSegmentSize
        {
            get { return m_minSegmentSize; }
            set { m_minSegmentSize = value; }
        }

        public int SegmentSize
        {
            get { return m_segmentSize; }
            set { m_segmentSize = value; }
        }
        private int m_segmentStartIndex;

        public int SegmentStartIndex
        {
            get { return m_segmentStartIndex; }
            set { m_segmentStartIndex = value; }
        }
        private int m_segmentEndIndex;

        public int SegmentEndIndex
        {
            get { return m_segmentEndIndex; }
            set { m_segmentEndIndex = value; }
        }

        // this flag will provide information about segmen changes
        private bool m_isChanged;

        public bool IsChanged
        {
            get { return m_isChanged; }
            set { m_isChanged = value; }
        }

        private double m_internalSimilarity;

        public double InternalSimilarity
        {
            get { return m_internalSimilarity; }
            set { m_internalSimilarity = value; }
        }

        public Segment(int segStartIndex,int segEndIndex, int minSegSize)
        {
            //if (segStartIndex > segEndIndex) throw new SegmentIndexException("The start index is more than end index in segment.");
            //else if (segStartIndex < 0 || segEndIndex < 0) throw new SegmentIndexException("Index in segment cannot be less than zero.");
            //else if (segEndIndex - segStartIndex < minSegSize) throw new SegmentIndexException("The Segment size is less then minimal segment size. Params StartInd:"+m_segmentStartIndex +" End Ind: "+ m_segmentEndIndex);

            m_segmentStartIndex = segStartIndex;
            m_segmentEndIndex = segEndIndex;
            m_segmentSize = segEndIndex - segStartIndex;
            m_minSegmentSize = minSegSize;
            m_isChanged = true;
            m_internalSimilarity = 0;
        }

        public void calculateSize()
        {
            m_minSegmentSize = m_segmentEndIndex - m_segmentStartIndex;
        }

        public int CompareTo(Segment _seg)
        {
            return m_segmentStartIndex.CompareTo(_seg.m_segmentStartIndex);
        }
      
    }
}
